package com.shujia.jinjie;

import com.shujia.util.MysqlTool;
import redis.clients.jedis.Jedis;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;

public class RedisInfoDemo {
    public static void main(String[] args) throws Exception {
        putData("蜀山区");
        putData("包河区");


    }
    public static void putData(String region) throws Exception {
        HashMap<String, String> shuShanMap = new HashMap<>();

        Connection conn = MysqlTool.getConnection();
        PreparedStatement p1 = conn.prepareStatement("select * from boss where areaDistrict=?");
        p1.setString(1, region);
        ResultSet resultSet = p1.executeQuery();
        while (resultSet.next()) {
            int id = resultSet.getInt("id");
            String s1 = resultSet.getString(1);
            String s2 = resultSet.getString(2);
            String s3 = resultSet.getString(3);
            String s4 = resultSet.getString(4);
            String s5 = resultSet.getString(5);
            String s6 = resultSet.getString(6);
            String s7 = resultSet.getString(7);
            String s8 = resultSet.getString(8);
            String s9 = resultSet.getString(9);
            String s10 = resultSet.getString(10);
            String s11 = resultSet.getString(11);
            String s12 = resultSet.getString(12);
            String s13 = resultSet.getString(13);
            String key = s3 + "_" + id;
            String value = s1 + "|" + s2 + "|" + s3 + "|" + s4 + "|" + s5 + "|" + s6 + "|" + s7 + "|" + s8 + "|" + s9 + "|" + s10 + "|" + s11 + "|" + s12 + "|" + s13;
            shuShanMap.put(key, value);
        }
        Jedis jedis = new Jedis("192.168.136.100",7000);
        jedis.hset("区域:"+region,shuShanMap);
    }
}
